You shouldn't need anything else. I see that I forgot a closing bracket on this line:
if( IsDlgButtonChecked( IDC_XXXX)
it should be:
if( IsDlgButtonChecked( IDC_XXXX))
It sounds like that line is always returning the same value. I bet that you have the button setup currently so that after you click the button, it becomes unlicked. In order to make the button "toggle" on and off, you need to use the UpdateUI function.
You will need to do a few things. You need to create a new variable, initialize it to a starting value, toggle it when you click the button, and then create a function to handle making the button stay pushed down.
In the KMotionCNCDlg.h file, declare a variable to hold the current button state.
bool PersistRestored;
bool m_bFloodOn;
In the KMotionCNCDlg.cpp file, in the constructor function initialize the new variable:
CKMotionCNCDlg::CKMotionCNCDlg(CWnd* pParent /*=NULL*/)
: CDlgX(pParent)
{
m_bFloodOn=FALSE;
In the message map section setup the message handler. Below the line:
BEGIN_MESSAGE_MAP(CKMotionCNCDlg, CDlgX)
Add a line:
ON_UPDATE_COMMAND_UI(IDC_XXXX, OnUpdateFlood)
In the KMotionCNCDlg.h file, towards the bottom where you see declarations starting with
afx_msg void ...
declare the new function by adding the line
afx_msg void OnUpdateFlood(CCmdUI* pCmdUI);
In the body of the KMotionCNCDlg.cpp file, add the new function to toggle the button state:
void CKMotionCNCDlg::OnUpdateFlood(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_bFloodOn);
}
Finally, change your button handler to:
void CKMotionCNCDlg: :OnBnClickedOnCo olant()
{
if(!m_bFloodOn)
{
Interpreter- >InvokeAction (8,FALSE) ;
}
else
{
Interpreter- >InvokeAction (9,FALSE) ;
}
m_bFloodOn = !m_bFloodOn
}